package com.hai.qtalk.service;

import java.util.List;

import com.hai.qtalk.base.BaseDAO;
import com.hai.qtalk.bean.Group;

/**
 * 好友分组的业务逻辑类
 * 对好友分组进行增删查改
 * @author xinhai
 *
 */
public class GroupService {

	private static BaseDAO<Group> gDao = new BaseDAO<Group>();
	
	/**
	 * 添加新的好友分组
	 * @param g
	 */
	public static void addGroup(Group g){
		gDao.save(g);
	}
	
	/**
	 * 删除某一好友分组
	 * @param g
	 */
	public static void deleteGroup(Group g){
		gDao.delete(g);
	}
	
	/**
	 * 更新某一好友分组
	 * @param g
	 */
	public static void updateGroup(Group g){
		gDao.update(g);
	}
	
	/**
	 * 根据用户ID查找好友分组列表
	 * @param userId
	 * @return
	 */
	public static List<Group> findAllGroup(int userId){
		System.out.println("userId为"+userId);
		List<Group> list=gDao.list("select g from Group g where g.user.UId = '"+userId+"'");
//		System.out.println("group list为");
//		for(Group g:list){
//			System.out.println(g.getGId());
//		}
		return list;
	}
}
